package cn.tedu.luban.demand.main.controller;

import cn.tedu.luban.demand.main.converter.DemandConverter;
import cn.tedu.luban.demand.main.service.DemandFrontService;
import cn.tedu.luban.demand.protocol.VO.RequestOrderListItemVO;
import cn.tedu.luban.demand.protocol.bo.RequestOrderBO;
import cn.tedu.luban.demand.protocol.query.RequestOrderQuery;
import com.tedu.inn.protocol.ListRecordTotalBO;
import com.tedu.inn.protocol.model.Result;
import com.tedu.inn.protocol.pager.PagerResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "requestOrder", tags = "需求订单接口")
@RequestMapping("/demand/order")
public class DemandFrontController {
    @Autowired
    private DemandFrontService demandFrontService;
    @Autowired
    private DemandConverter demandConverter;
    @PostMapping(value = "search")
    @ApiOperation("需求订单列表")
    public Result<PagerResult<RequestOrderListItemVO>> queryRequestOrder(@RequestBody RequestOrderQuery requestOrderQuery) {
        ListRecordTotalBO<RequestOrderBO> accessProviderListTotalRecord =
            this.demandFrontService.queryRequestOrder(requestOrderQuery);
        return new Result(this.demandConverter.assemblePagerResult(accessProviderListTotalRecord, requestOrderQuery));
    }
}
